package mock

import (
	"errors"
	"fmt"
)

// RedisError defines the redis protocol error
type RedisError error

const (
	// UnKnownCommandStr is the command not find
	unKnownCommandStr = "unknown command '%s'"
	// WrongArgs is for wrong number of arguments error
	wrongArgs = "ERR wrong number of arguments for '%s' command"
)

var (
	// OK is the simple string "OK" returned to client
	OK = "OK"

	// Queued is the simple string "QUEUED" return to client
	Queued = "QUEUED"

	// ErrNoAuth authentication required
	ErrNoAuth = errors.New("NOAUTH Authentication required")

	// ErrAuthInvalid invalid password
	ErrAuthInvalid = errors.New("ERR invalid password")

	// ErrAuthUnSet Client sent AUTH, but no password is set
	ErrAuthUnSet = errors.New("ERR Client sent AUTH, but no password is set")

	// ErrInteger value is not an integer or out of range
	ErrInteger = errors.New("ERR value is not an integer or out of range")

	// ErrFloat value is not a valid float
	ErrFloat = errors.New("ERR value is not a valid float")

	//argument min or max isn't float
	ErrMinOrMaxNotFloat = errors.New("ERR min or max is not a float")

	// ErrIndex offset is out of range
	ErrIndex = errors.New("ERR index out of range")

	// ErrSyntax syntax error
	ErrSyntax = errors.New("ERR syntax error")

	// ErrNoSuchKey reteurn on lset for key which no exist
	ErrNoSuchKey = errors.New("ERR no such key")

	// ErrTypeMismatch Operation against a key holding the wrong kind of value
	ErrTypeMismatch = errors.New("WRONGTYPE Operation against a key holding the wrong kind of value")
)

// ErrUnKnownCommand return RedisError of the cmd
func ErrUnKnownCommand(cmd string) error {
	return fmt.Errorf(unKnownCommandStr, cmd)
}

// ErrWrongArgs return RedisError of the cmd
func ErrWrongArgs(cmd string) error {
	return fmt.Errorf(wrongArgs, cmd)
}
